package cn.sun.basic.service.impl;

import cn.sun.basic.mapper.BaseMapper;
import cn.sun.basic.service.IBaseService;
import cn.sun.basic.util.PageBean;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;


public class BaseServiceImpl<T,T2>  implements IBaseService<T,T2> {
    
    @Autowired
    private BaseMapper<T,T2> mapper;
    @Override
    public void save(T t) {
        mapper.save(t);
    }

    @Override
    public void update(T t) {
        mapper.update(t);
    }

    @Override
    public void delete(Long id) {
        mapper.delete(id);
    }


    @Override
    public PageBean<T> findPage(T2 t2) {
        Integer total = mapper.findNum(t2);
        if (total ==null){
            return new PageBean<>();
        }
        List<T> datas = mapper.findPage(t2);
        return new PageBean<>(total,datas);
    }

    @Override
    public List<T> findAll() {
        return mapper.findAll();
    }

    @Override
    public T findById(Long id) {
        return mapper.findById(id);
    }

}
